Skip to content

Conversation

@dynst
Copy link
Contributor

@dynst dynst commented Aug 6, 2025

Node 20 is the current minimum supported version, and node 20 is nodenext as of TypeScript 5.8. (TypeScript 5.9 will add an explicit node20 setting. microsoft/TypeScript#61805)

https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping#node-20

https://www.typescriptlang.org/docs/handbook/modules/reference.html#the-module-compiler-option

With this change, await import() is no longer transpiled into a require() call, and webpack's resolve.fallback (which is performed at build time) doesn't seem to work on dynamic imports (maybe it does with some extra configuration...but documentation doesn't say what). Unlike with require() webpack trusts that it'll resolve at runtime, so long as asyncChunks: true. So turn async chunks off, unit tests don't need that.

(This appears to be an entirely undocumented and convoluted footgun interaction between the configuration options.)

https://webpack.js.org/configuration/output/#outputasyncchunks
https://webpack.js.org/configuration/resolve/
webpack/webpack#18028 (reply in thread)

@dynst dynst force-pushed the tsconfig-node20 branch from 717dd87 to fc85bb9 Compare August 6, 2025 17:44
no ChunkLoadError is possible then.
@webmaster128
Copy link
Member

Let's upgrade to TS 5.9 (#1780), then look into this

@dynst dynst force-pushed the tsconfig-node20 branch 2 times, most recently from fc301c0 to 3955fe2 Compare August 6, 2025 22:11
dynst added 2 commits August 6, 2025 22:13
Effectively synonymous with nodenext.
already implied by tsconfig compilerOptions.module=node20
target: target,
entry: globSync("./build/**/*.spec.js", { dotRelative: true }).sort(),
output: {
asyncChunks: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need this for all webpack config files?

"module": "commonjs",
"moduleResolution": "node",
"lib": ["es2022"],
"target": "es2022",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should go to the CHANGELOG I guess as users will receive more modern JS output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants